{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "26011dd2-535d-4408-b31f-30519ad172b6",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "The tokenizer class you load from this checkpoint is not the same type as the class this function is called from. It may result in unexpected tokenization. \n",
      "The tokenizer class you load from this checkpoint is 'GPT4Tokenizer'. \n",
      "The class this function is called from is 'GPT2TokenizerFast'.\n"
     ]
    }
   ],
   "source": [
    "from transformers import GPT2TokenizerFast\n",
    "\n",
    "tokenizer = GPT2TokenizerFast.from_pretrained('Xenova/text-embedding-ada-002')\n",
    "assert tokenizer.encode('hello world') == [15339, 1917]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "ce48aafc-1ffe-429e-a2a5-73a03f718336",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[15339, 1917]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tokenizer.encode('hello world')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "40cfde48-c66e-4ce1-963f-3ce5f215d32b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[57668, 53901, 3574, 244, 98220]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tokenizer.encode('你好世界')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "ed8aa3b4-bf3a-466c-bac8-c815f6802377",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[37046, 76207, 109, 44388, 19483, 3574, 244, 98220]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tokenizer.encode('我爱这个世界')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "be7fde29-7cc8-40fa-9041-f8d70350d2f2",
   "metadata": {},
   "outputs": [],
   "source": [
    "print(\"ok!\")\n",
    "del tokenizer\n",
    "exit()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
